package com.som.beanconvert.data2.output;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.ss.usermodel.Row;

import com.som.bean.data2.output.NotAllData;
import com.som.beanconvert.ExcelColumnProcessInf;
import com.som.beanconvert.ExcelDataParseOutputInf;

/**
 * 通过LOOPBACK地址让数据二与数据三关联 以设备采集的数据为准 输出列为: IP地址 路由(network) 网元信息 区县
 * 
 * @author liujun
 * @date 2016年4月8日
 * @verion 0.0.1
 */
public class NotAllDataExcelOutput extends NotAllData implements ExcelDataParseOutputInf<NotAllData>, ExcelColumnProcessInf
{

	public void parseExcelRow(NotAllData beaninfo, Row row)
	{
		HSSFRow hrow = (HSSFRow) row;

		// 设置ip信息
		HSSFCell cellIp = hrow.createCell(0);
		cellIp.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellIp.setCellValue(beaninfo.getIpaddress());

		// 设置路由(network)
		HSSFCell cellMask = hrow.createCell(1);
		cellMask.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellMask.setCellValue(beaninfo.getNetwork());

		// 网元信息
		HSSFCell cellNe = hrow.createCell(2);
		cellNe.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellNe.setCellValue(beaninfo.getNeInfo());

		HSSFCell cellArea = hrow.createCell(3);
		cellArea.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellArea.setCellValue(beaninfo.getAreainfo());
	}

	public static void main(String[] args)
	{
		Map<String, String> map = new LinkedHashMap<String, String>();

		for (int i = 0; i < 100; i++)
		{
			map.put(String.valueOf(i), String.valueOf(i));
		}

		Iterator<Entry<String, String>> mapIter = map.entrySet().iterator();

		Entry<String, String> entry = null;

		while (mapIter.hasNext())
		{
			entry = mapIter.next();
			System.out.println(entry.getKey() + ":" + entry.getValue());
		}
	}

	public void setExcelColumn(Map<String, String> column, Row row)
	{
		HSSFRow hrow = (HSSFRow) row;

		// 设置ip信息
		HSSFCell cellIp = hrow.createCell(0);
		cellIp.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellIp.setCellValue("IP");

		// 设置路由(network)
		HSSFCell cellMask = hrow.createCell(1);
		cellMask.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellMask.setCellValue("路由(network)");

		// 网元信息
		HSSFCell cellNe = hrow.createCell(2);
		cellNe.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellNe.setCellValue("网元信息");

		// 区县信息
		HSSFCell cellArea = hrow.createCell(3);
		cellArea.setCellType(HSSFCell.CELL_TYPE_STRING);
		cellArea.setCellValue("区县信息");
	}

}
